package com.ruoyi.web.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SuperOrderReturnImg;
import com.ruoyi.system.service.ISuperOrderReturnImgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 退货订单图片Controller
 * 
 * @author ruoyi
 * @date 2025-08-13
 */
@RestController
@RequestMapping("/order/img")
public class SuperOrderReturnImgController extends BaseController
{
    @Autowired
    private ISuperOrderReturnImgService superOrderReturnImgService;

    /**
     * 查询退货订单图片列表
     */
    @PreAuthorize("@ss.hasPermi('order:img:list')")
    @GetMapping("/list")
    public TableDataInfo list(SuperOrderReturnImg superOrderReturnImg)
    {
        startPage();
        List<SuperOrderReturnImg> list = superOrderReturnImgService.selectSuperOrderReturnImgList(superOrderReturnImg);
        return getDataTable(list);
    }

    /**
     * 导出退货订单图片列表
     */
    @PreAuthorize("@ss.hasPermi('order:img:export')")
    @Log(title = "退货订单图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SuperOrderReturnImg superOrderReturnImg)
    {
        List<SuperOrderReturnImg> list = superOrderReturnImgService.selectSuperOrderReturnImgList(superOrderReturnImg);
        ExcelUtil<SuperOrderReturnImg> util = new ExcelUtil<SuperOrderReturnImg>(SuperOrderReturnImg.class);
        util.exportExcel(response, list, "退货订单图片数据");
    }

    /**
     * 获取退货订单图片详细信息
     */
    @PreAuthorize("@ss.hasPermi('order:img:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(superOrderReturnImgService.selectSuperOrderReturnImgById(id));
    }

    /**
     * 新增退货订单图片
     */
    @PreAuthorize("@ss.hasPermi('order:img:add')")
    @Log(title = "退货订单图片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SuperOrderReturnImg superOrderReturnImg)
    {
        return toAjax(superOrderReturnImgService.insertSuperOrderReturnImg(superOrderReturnImg));
    }

    /**
     * 修改退货订单图片
     */
    @PreAuthorize("@ss.hasPermi('order:img:edit')")
    @Log(title = "退货订单图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SuperOrderReturnImg superOrderReturnImg)
    {
        return toAjax(superOrderReturnImgService.updateSuperOrderReturnImg(superOrderReturnImg));
    }

    /**
     * 删除退货订单图片
     */
    @PreAuthorize("@ss.hasPermi('order:img:remove')")
    @Log(title = "退货订单图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(superOrderReturnImgService.deleteSuperOrderReturnImgByIds(ids));
    }
}
